home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / C / Code Resources / PopupCDEF 1.3 / Projects / CDEF / Source / PopupLib.h < prev   
Encoding:
C/C++ Source or Header  |  1995-10-10  |  4.9 KB  |  143 lines  |  [TEXT/CWIE]

  1. /* See the file Distribution for distribution terms.
  2.     (c) Copyright 1994 Ari Halberstadt */
  3.     
  4. #pragma once
  5.  
  6. #ifndef POPUP_LIBRARY
  7. #define POPUP_LIBRARY
  8.  
  9. #include <QDOffscreen.h>
  10. #include "PopupCDEF.h"
  11.  
  12. #ifdef __cplusplus
  13. extern "C" {
  14. #endif
  15.  
  16. #if PRAGMA_ALIGN_SUPPORTED
  17.     #pragma options align=mac68k
  18. #endif
  19.  
  20. /* Structure of a glue handle for 68K and PowerPC. The 68K version is based on
  21.     "Inside Macintosh: PowerPC System Software", p1-35. */
  22. typedef union {
  23.     struct {
  24.         unsigned long lea;        /* lea pc+8, a0 */
  25.         unsigned short move;        /* movea.l (a0) a0 */
  26.         unsigned short jmp;        /* jmp (a0) */
  27.         ProcPtr proc;                /* destination address */
  28.     } m68k;
  29.     struct {
  30.         RoutineDescriptor descriptor;
  31.     } ppc;
  32. } PopupGlueUnion, *PopupGluePtr, **PopupGlueHandle;
  33.  
  34. /* rectangles defining the various areas of a popup menu */
  35. typedef struct {
  36.     Rect bounds;                        /* rectangle around all of popup */
  37.     Rect hilite;                        /* hilited when a selection is being made */
  38.     Rect title;                            /* contains the popup's title */
  39.     Rect selection;                    /* contains the currently selected item and the triangle */
  40.     Rect item;                            /* contains the currently selected item */
  41.     Rect triangle;                        /* contains the triangle */
  42. } PopupRectanglesType;
  43.  
  44. /* structure containing all the data needed by the popup menu */
  45. typedef struct {
  46.  
  47.     /* These first two fields will never be changed, other fields may change. */
  48.     PopupPrivateType privateData;    /* for compatability with Apple's CDEF */
  49.     short                version;            /* version of the code that created this popup menu */
  50.  
  51.     /* Fields specified on creation of the popup menu. */
  52.     GrafPtr            port;                /* port to draw into */
  53.     MenuHandle        menu;                /* handle to menu */
  54.     ControlHandle    ctl;                /* handle to control */
  55.     Rect                maxbounds;        /* maximum bounding rectangle of popup */
  56.     
  57.     /* For patching the menu definition function. */
  58.     Handle            menuProc;        /* glue to call our own MDEF */
  59.     
  60.     /* Information needed when drawing. */
  61.     struct {
  62.         GWorldPtr    gworld;            /* offscreen graphics world */
  63.         GDHandle        gdevice;            /* graphics device to draw into */
  64.         short            gdepth;            /* pixel depth of graphics device */
  65.         RGBColor        fore;                /* popup port's foreground color */
  66.         RGBColor        back;                /* popup port's background color */
  67.     } draw;
  68.     
  69.     /* Internal state information. */
  70.     PopupRectanglesType r;            /* rectangles enclosing areas of the popup menu */
  71.     struct {
  72.         short            current;            /* currently selected item number */
  73.         short            drawSetup;        /* incremented after drawing environment is setup */
  74.         Boolean        createdMenu;    /* true means CDEF created menu */
  75.     } state;
  76.     
  77.     /* User settable attributes of the menu. External functions
  78.         are provided to manipulate these fields. */
  79.     struct {
  80.         struct {
  81.             Handle    string;            /* popup's title string */
  82.             Style        style;            /* style of popup's title */
  83.             short        width;            /* width of title; 0 if resized dynamically */
  84.             char        just;                /* text justification */
  85.         } title;
  86.         char            mark;                /* character used to mark current item */
  87.         Boolean        draw:1;            /* false disables drawing and calculating */
  88.         Boolean        enabled:1;        /* true if menu is enabled */
  89.         Boolean        typeIn:1;        /* true shows only triangle, like a type-in menu */
  90.         Boolean        windowFont:1;    /* true uses window font, not system font */
  91.         Boolean        fixedWidth:1;    /* true uses fixed width for menu */
  92.         Boolean        bevel:1;            /* true draws a bevel */
  93.     } attr;
  94.     
  95. } PopupType, *PopupPtr, **PopupHandle;
  96.  
  97. #if PRAGMA_ALIGN_SUPPORTED
  98.     #pragma options align=reset
  99. #endif
  100.  
  101. void PopupGlueInit(PopupGlueUnion *glue, ProcPtr proc, ProcInfoType info);
  102.  
  103. Boolean PopupValid(PopupHandle popup);
  104.  
  105. void PopupCalculate(PopupHandle popup);
  106. void PopupDraw(PopupHandle popup);
  107. short PopupSelect(PopupHandle popup);
  108. Boolean PopupWithin(PopupHandle popup, Point pt);
  109.  
  110. short PopupVersion(PopupHandle popup);
  111. short PopupCurrent(PopupHandle popup);
  112. void PopupCurrentSet(PopupHandle popup, short current);
  113. void PopupDrawSet(PopupHandle popup, Boolean draw);
  114. void PopupEnableSet(PopupHandle popup, Boolean enabled);
  115. void PopupMarkSet(PopupHandle popup, char mark);
  116. void PopupTypeInSet(PopupHandle popup, Boolean typein);
  117. void PopupBevelSet(PopupHandle popup, Boolean bevel);
  118. void PopupBounds(PopupHandle popup, Rect *bounds);
  119. void PopupBoundsSet(PopupHandle popup, const Rect *bounds);
  120. void PopupTitle(PopupHandle popup, Str255 title);
  121. void PopupTitleSet(PopupHandle popup, const Str255 title);
  122. void PopupTitleWidthSet(PopupHandle popup, short width);
  123. void PopupTitleStyleSet(PopupHandle popup, Style style);
  124. void PopupWindowFontSet(PopupHandle popup, Boolean wfont);
  125. void PopupFixedWidthSet(PopupHandle popup, Boolean fixedwidth);
  126. void PopupJustSet(PopupHandle popup, short just);
  127.  
  128. PopupHandle PopupBegin(GrafPtr port,
  129.     MenuHandle menu,
  130.     const Rect *maxbounds,
  131.     ControlHandle ctl);
  132. void PopupEnd(PopupHandle popup);
  133.  
  134. pascal long PopupCDEF(short var, ControlHandle ctl, short msg, long param);
  135. void PopupCDEFAttach(ControlHandle ctl);
  136. void PopupCDEFDetach(ControlHandle ctl);
  137.  
  138. #ifdef __cplusplus
  139. }
  140. #endif
  141.  
  142. #endif /* POPUP_LIBRARY */
  143.